package com.powernode.work.controller;

import com.powernode.commons.utils.ResponseData;
import com.powernode.work.bean.TranHistoryBean;
import com.powernode.work.service.TranHistoryService;
import com.powernode.work.service.TranService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("history")
@Api(tags = "交易的历史记录")
public class TranHistoryController {
    @Autowired
    private TranHistoryService service;

    @GetMapping("getHistoryByTranId")
    @ApiOperation("根据交易的id查询历史记录")
    public ResponseData getHistoryByTranId(String tranId){
        return service.findByTranId(tranId);
    }

    @PostMapping
    @ApiOperation("添加历史")
    public ResponseData add(@RequestBody TranHistoryBean historyBean){
        return service.add(historyBean);
    }

    @PutMapping
    @ApiOperation("修改历史")
    public ResponseData edit(@RequestBody TranHistoryBean historyBean){
        return service.modify(historyBean);
    }
}
